﻿@{
    Layout = null;
    ViewData["Title"] = "编辑订单";
    var User = ViewBag.User as List<BuyWithoutLoseMoney.Core.Models.User>;
}
@model BuyWithoutLoseMoney.Core.Models.Order;
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <div>
        <div class="layui-card">
            <div class="layui-card-header">编辑订单</div>
            <div class="layui-card-body">
                <form class="layui-form">
                    <input type="hidden" name="Id" value="@Model.Id" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户</label>
                        <div class="layui-input-block">
                            <select name="UserId" lay-verify="required">
                                @foreach (var item in User)
                                {
                                    <option value="@item.Id">@item.NickName</option>
                                }
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品总价</label>
                        <div class="layui-input-block">
                            <input type="text" name="TotalMoney" archive="@Model.TotalMoney" required lay-verify="required" placeholder="请输入商品总价" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            @if (Model.Status == 1)
                            {
                                <input type="radio" name="Status" value="1" title="未付款" checked />
                                <input type="radio" name="Status" value="2" title="已付款" />
                                <input type="radio" name="Status" value="3" title="未发货" />
                                <input type="radio" name="Status" value="4" title="已发货" />
                            }
                            else  @if (Model.Status == 2)
                            {
                                <input type="radio" name="Status" value="1" title="未付款"/>
                                <input type="radio" name="Status" value="2" title="已付款" checked />
                                <input type="radio" name="Status" value="3" title="未发货" />
                                <input type="radio" name="Status" value="4" title="已发货" />
                            }
                            else  @if (Model.Status == 3)
                            {
                                <input type="radio" name="Status" value="1" title="未付款"  />
                                <input type="radio" name="Status" value="2" title="已付款" />
                                <input type="radio" name="Status" value="3" title="未发货" checked />
                                <input type="radio" name="Status" value="4" title="已发货" />
                            } else  @if (Model.Status == 4)
                            {
                                <input type="radio" name="Status" value="1" title="未付款"  />
                                <input type="radio" name="Status" value="2" title="已付款" />
                                <input type="radio" name="Status" value="3" title="未发货" />
                                <input type="radio" name="Status" value="4" title="已发货" checked />
                            }
                          
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">收货方式</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="ReceivingType" value="@Model.ReceivingType" required lay-verify="required" placeholder="请输入收货方式" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">收货地址</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="ReceivingAddress" value="@Model.ReceivingAddress" required lay-verify="required" placeholder="请输入收货地址" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="CreateTime" value="@Model.CreateTime.ToString()" id="ID-laydate-type-datetime1" placeholder="请选择创建时间">
                        </div>
                    </div>、
                    <div class="layui-form-item">
                        <label class="layui-form-label">到货时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="ArriveTime" value="@Model.ArriveTime.ToString()" id="ID-laydate-type-datetime2" placeholder="请选择到货时间">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付方式</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="Paymethod" value="@Model.Paymethod" required lay-verify="required" placeholder="请输入支付方式" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="EditForm">修改</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="/js/vue.js"></script>
    <script src="/layui/layui.js"></script>
        layui.use(["form", 'layer', 'laydate'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var laydate = layui.laydate
            laydate.render({
                elem: '#ID-laydate-type-datetime1',
                type: 'datetime'
            });
            laydate.render({
                elem: '#ID-laydate-type-datetime2',
                type: 'datetime'
            });
            //修改
            form.on('submit(EditForm)', function (data) {
                $.post("/admin/new/edit", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            parent.window.location.href = "/admin/new/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
</body>
</html>